enable_testing()
find_package(GTest MODULE REQUIRED)

file(COPY ../config.ini DESTINATION .)

add_executable(index_test index/index_page_test.cpp index/index_segment_test.cpp index/linear_index_test.cpp)
target_link_libraries(index_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} index)
add_test(NAME index_test COMMAND index_test)

add_executable(perf_test perf/sequential_read_test.cpp perf/mem_layout_write_test.cpp
        ../src/mem/active_data_page.cpp)
target_link_libraries(perf_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} type)
add_test(NAME perf_test COMMAND perf_test)

add_executable(binary_write_test perf/binary_write_test.cpp)
target_link_libraries(binary_write_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} benxdb)
add_test(NAME binary_write_test COMMAND binary_write_test)

add_executable(database_test access/database_test.cpp)
target_link_libraries(database_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} benxdb)
add_test(NAME database_test COMMAND database_test)

add_executable(storage_test storage/disk_manager_test.cpp)
target_link_libraries(storage_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} storage type)
add_test(NAME storage_test COMMAND storage_test)

add_executable(disk_test storage/disk_test.cpp)
target_link_libraries(disk_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} storage type)
add_test(NAME disk_test COMMAND disk_test)

add_executable(data_chunk_io_test storage/data_chunk_io_test.cpp)
target_link_libraries(data_chunk_io_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} storage type)
add_test(NAME data_chunk_io_test COMMAND data_chunk_io_test)

add_executable(table_manager_test mem/table_manager_test.cpp)
target_link_libraries(table_manager_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} mem catelog)
add_test(NAME table_manager_test COMMAND table_manager_test)

add_executable(compressor_test compress/minilzo_test.cpp compress/compressor_test.cpp compress/zlib_test.cpp
        ../src/compress/minilzo.c ../src/compress/compressor.cpp ../include/compress/compressor.h
        ../src/compress/lz4.c)
target_link_libraries(compressor_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ZLIB::ZLIB)
add_test(NAME compressor_test COMMAND compressor_test)

add_executable(catelog_test catelog/table_test.cpp)
target_link_libraries(catelog_test PUBLIC ${GTEST_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} catelog common)
add_test(NAME catelog_test COMMAND catelog_test)